<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:costa="http://stdio.costa/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	template="/WEB-INF/layout/template.xhtml">
	<f:metadata>
		<f:viewParam name="id" value="#{classificationHome.id}">
			<f:convertNumber integerOnly="#{true}" />
		</f:viewParam>
		<f:event type="preRenderView" listener="#{classificationHome.postConstruct}" />
	</f:metadata>
	<ui:define name="content">
		<h:form prependId="false">
			<h:panelGroup id="classificationDetail">
				<h:panelGrid columns="4">
					<h:outputLabel for="name" />
					<rich:inplaceInput id="name" defaultLabel="#{messages.name}" value="#{classificationHome.entity.name}" />
					<rich:message for="name" />
					<a4j:commandButton action="#{classificationHome.save}" value="#{messages.save}" render="classificationDetail"/>
				</h:panelGrid>
				<h:panelGrid columns="4" id="classificationTree">
					<rich:tree toggleType="client" var="classification" rendered="#{not empty classificationConverter.list}">
						<rich:treeModelRecursiveAdaptor roots="#{classificationConverter.list}" nodes="#{classification.subClassifications}">
							<rich:treeNode style="display:#{classification.deleted ? 'none' : ''}">
								<rich:inplaceInput id="name" defaultLabel="#{messages.name}" value="#{classification.name}" />
								<a4j:commandButton action="#{classificationConverter.save}" render="classificationTree" value="#{messages.save}">
									<f:setPropertyActionListener target="#{classificationConverter.selectedNode}" value="#{classification}" />
								</a4j:commandButton>
								<a4j:commandButton action="#{classificationConverter.addSubClassification}" value="#{messages.add}" render="classificationTree" rendered="#{not empty classification.id}">
									<f:setPropertyActionListener target="#{classificationConverter.selectedNode}" value="#{classification}" />
								</a4j:commandButton>
								<a4j:commandButton action="#{classificationConverter.delete}" value="#{messages.delete}" render="classificationTree" rendered="#{classification.deletable}">
									<f:setPropertyActionListener target="#{classificationConverter.selectedNode}" value="#{classification}" />
								</a4j:commandButton>
								<rich:message for="name" />
		               		</rich:treeNode>
						</rich:treeModelRecursiveAdaptor>
					</rich:tree>
				</h:panelGrid>
			</h:panelGroup>
		</h:form>
	</ui:define>
</ui:composition>
